package join;

import join.util.GetTaggedFileSplit;
import join.util.StringArrayUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author zhengjiasen
 * @date 2018/3/3
 * <p>
 * 源文件只有一个号码；输出以号码为key ,号码+路径的hashcode 为value。
 */
public class SrcDataFileMapper extends Mapper<Object, Text, Text, Text> {

    /**
     * 定义一个字段，用于存放Map输出的value
     */
    private Text text = new Text();
    private Text outKey = new Text();

    @Override
    public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
//        text.set("A".concat(value.toString()));
//        // 每个map 输出以FileSplit
//        context.write(value, text);
        String[] split = value.toString().split(",");
        outKey.set(split[0]);
        text.set("A".concat(value.toString()));
        context.write(outKey, text);
    }

}
